class Worker < ActiveRecord::Base
  belongs_to :team
  has_many :maintenances
  has_many :records

  def self.findWorkersByTeam team_id,start,limit
    find(:all,:conditions => ['team_id = ? AND is_locked = 0',team_id],:offset => start, :limit => limit,:order=> 'number')
  end

  def self.countWorkersByTeam team_id
    count(:all,:conditions => ['team_id = ? AND is_locked = 0',team_id])
  end

  def self.getByName name
    find(:all,:conditions => ['name like ?','%'+name+'%'])
  end
end
